home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Demos
/
A.D. Software
/
OOFILE
/
Buildable, limited OOFILE
/
samples
/
ooftst05.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-03-07
|
2KB
|
71 lines
// Copyright 1994 A.D. Software. All Rights Reserved
// OOFTEST5
// Simple stream I/O is used to interact with the user.
// to demonstrate the date parsing
#include "oofile.hpp"
void getStringMaybeBlank(char* readInto);
int
main()
{
cout << "OOFILE Validation Suite - Test 5\n"
<< "Today's date is : " << dbDate::today << endl << endl
<< "Simple test to try the input routines of the dbDate type" << endl << endl
<< "A number of sample entries are shown."
<< endl << endl;
unsigned short year, month, day;
cout << "change the default date order to Month, Day Year" << endl;
dbDate::sDefaultDateOrder=dbDate::orderMDY;
char * test[] = { "Jan 15 2001",
"Feb, 24, 1923",
"3/2/67",
"4-30-1988",
"MAY12:1971",
"June17",
"september 4th",
"oct 1st 38",
"11/19" };
unsigned short numtests = 9;
oofDate aDate; // define a standalone date variable
aDate = dbDate::currentDate();
cout << "The current date is: " << aDate << endl;
oofDate twoWeeksAgo = aDate-14;
cout << "Two weeks ago was: " << twoWeeksAgo << endl;
for (int i = 0; i < numtests; ++i) {
cout << "Attempting to process the date: " << test[i] << endl;
if (dbDate::chars2ymd(test[i],year,month,day))
cout << " = (YMD) " << year << "/" << month << "/" << day << endl << endl;
else
cout << "bad date" << endl;
}
/*
// uncomment this section if you want to try entering dates yourself
for (;;) {
cout << "Enter a date (MDY): " << flush;
if (dbDate::istream2ymd(cin, year, month, day)) {
cout << " = (YMD) " << year << "/" << month << "/" << day << endl << endl;
cin.ignore(INT_MAX, '\n');
cin.clear();
}
else {
cout << "bad date" << endl;
break;
}
}
*/
cout << endl << "done" << endl;
return EXIT_SUCCESS;
}